<%--
  Created by IntelliJ IDEA.
  User: zhuhongyu
  Date: 2022/6/19
  Time: 22:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>绵阳城市学院宿舍管理系统</title>
    <link rel="icon" href="images/3.icon">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="layui/css/layui.css" rel="stylesheet">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <style>
        #test tr{
            text-align: center;
        }
        body {
            height: 100%;
            background: url('images/1.jpg') no-repeat;
            background-position-y: -120px;
        }
        table{
            opacity: 0.8;
            color: black;
        }
        table td{
            color: black;
        }
    </style>
</head>
<body>


<table class="layui-hide" id="test" style="text-align: center"></table>


<script type="text/html" id="checkboxTpl">

    <input type="checkbox" name="lock" value="{{d.buildingnub}}" title="满" lay-filter="lockDemo" {{ d.state=='满'?'checked':''}}>
</script>

<script src="layui/layui.js"></script>
<script>
    layui.use('table', function(){
        var table = layui.table
            ,form = layui.form;
        table.render({
            elem: '#test'
            ,url:'manageDormitory'
            ,cellMinWidth: 80
            ,cols: [[
                {field:'building', title:'宿舍楼', width:200, unresize: true}
                ,{field:'buildingnub', title:'寝室号'}
                ,{field:'state', title:'是否锁定', templet: '#checkboxTpl'}
            ]]
        });

        form.on('checkbox(lockDemo)', function(obj){
            var a=0;
            if(obj.elem.checked){
                a=1;
            }
            $.ajax({
                type: "post",
                url: "editBuilding?buildingnub="+this.value+"&state="+a
            })
        });
    });
</script>
</body>
</html>